@extends('layouts.layouts')
@section('title')
    <title>视频页面</title>
@endsection
@section('content')
<link rel="stylesheet" href="/lib/layer/theme/default/layer.css"/>
    <script type="text/javascript" src="/lib/layer/layer.js"></script>
<div class="content">
        <div class="header">       
            <h1 class="page-title">分销打卡课程列表</h1>
             <ul class="breadcrumb"></ul>
        </div>
        <div class="main-content">

<div class="btn-toolbar list-toolbar">
                <form class="form-inline" action="" method="get">
					<!-- <a href="/video/add"><button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-home"></i> 添加视频</button></a> -->
          <a href="/dis/coursea"><button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-home"></i> 添加课程</button></a>
                    <div class="form-group">
                        <input type="text" class="form-control" name="title" placeholder="课程链接标题" value="">
                    </div>
                    <button type="submit" class="btn btn-default">筛选</button>
                </form>
            </div>
 <div class="panel panel-default">

<div class="panel-heading no-collapse">视频列表<!-- <span class="label label-warning">+10</span> --></div>
<table class="table table-bordered table-striped">
  <thead>
    <tr>
      <th>序号</th>
      <th>视频名称</th>
      <th>封面图</th>
      <th>海报图</th>
      <th>原价--售价</th>
      <th>课时数量</th>
      <th>关联视频</th>
      <th>排序值</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody>
<div>
@foreach($list as $v)
		<tr id="course_{{$v->id}}">
				  <td>{{$v->id}}</td>
				  <td>{{$v->title}}</td>
				  <td><img class="pimg" height='80' src="{{env('IMG_URL')}}{{$v->cover_url}}" /></td>
          <td><img class="pimg" height='80' src="{{env('IMG_URL')}}{{$v->poster_url}}" /></td>
				  <td>{{$v->o_price}}----{{$v->price}}</td>
          <td>{{$v->course_num}}</td>
          <td class="autocut" data-attr="{{dis_course($v->course_ids)}}">点击查看</td>
          <td>{{$v->orderby}}</td>
				  <td width="15%">
					  <a href="/dis/courseu/{{$v->id}}"><i class="fa fa-pencil"></i>编辑</a>&nbsp;|
					  <a href="javascript:;"  data-id="{{$v->id}}" onclick="articleDelete(this)"><i class="fa fa-trash-o"></i>删除</a>&nbsp;
				  </td>
		</tr>
@endforeach
</div>

  </tbody>
</table>
</div>

  <ul class="pagination">
  {{$list->appends(['title'=>$title])->render()}}
  </ul>
</div>


</div>
    <script type="text/javascript">
        $(".autocut").click(function(){
            var obj = $(this);
            var data = obj.attr("data-attr");
            swal(data);
        })
    </script>

    <script src="lib/bootstrap/js/bootstrap.js"></script>
    <script>
        $(".link").click(function(){
           // console.log($(this).next());
            $(this).next().toggleClass('submenu1');
        })

        function articleDelete(obj){
            var id = $(obj).attr('data-id');
            var _token = '{{csrf_token()}}';
            var data = {id:id,_token:_token};
            layer.confirm('确定删除吗？', {
                btn: ['是', '否'],
            }, function(index){
                $.ajax({
                    url:'/dis/coursed',
                    data:data,
                    type:'POST',
                    dataType: 'json',
                    success:function(res){
                        layer.alert(res.message);
                        if(res.code == 0){
                            $("#course_"+id).remove();
                        }

                    }
                });
                layer.close(index);
                return true;
            }, function(index){
                layer.close(index);
            });

        }
    </script>

@endsection
